# -*- coding: utf-8 -*-
"""
Created on Fri Aug 26 12:22:44 2022

@author: xiong
"""
import re 
import hashlib
import time

def mqPostsTemplate(data,taskid):

    userid = data["user_id"]
    md5_userid = hashlib.md5(userid.encode(encoding='UTF-8')).hexdigest()

    vcid = hashlib.md5(str(time.time()).encode(encoding='UTF-8')).hexdigest()
           
    return {
    "type":"Facebook",
    	"post":[{
    		"vc_id": vcid,
    "vc_target_user_id": md5_userid,
    "vc_userid": data["user_id"],
    "vc_nickname": data["nick_name"],
    "vc_username": "",
    "vc_photo_url": "",
    "vc_photo_url_local": "",
    "vc_postid": data["post_id"],
    "text_post_content": data["posts_text"],
    "text_picture_url": ",".join(i[0] for i in data["image_url_and_description"]),
    "text_picture_url_local": ",".join(i[1] for i in data["image_url_and_description"]),
    "vc_reply_count": data["comment_num"],
    "vc_forward_count": data["share_num"],
    "vc_favorites_count": data["like_num"],
    "vc_forward_url": "",
    "vc_forward_title": "",
    "vc_forward_content": "",
    "vc_forward_user": "",
    "dt_forward_date": " ",
    "vc_video_url": ",".join(i[0] for i in data["vidio_url"]),
    "vc_video_url_local": ",".join(i[1] for i in data["vidio_url"]),
    "vc_video_picture_url": "",
    "vc_video_picture_url_local": "",
    "dt_pubdate": "",
    "text_content": "",
    "dt_gather_time": time.strftime("%Y-%m-%d %H:%M:%S", data["dt_gather_time"]),
    "vc_task_id": taskid,
    "vc_task_type": "",
    "vc_md5": hashlib.md5((taskid+data["post_id"]).encode(encoding='UTF-8')).hexdigest(),
    "vc_cookie_str": "",
    "vc_gather_user_id": "",
    "vc_post_type": "",
    "vc_fb_dtsg": "",
    "vc_feedback_id": "",
    "vc_fb_dtsg_ag": "",
    "vc_client_type": "",
    "vc_story_fbid": data["post_fbid"]
    	}],
    	"downLoadPaths":["facebook/auto/201905/b67606729ce3aafd17f969e74adcfe97.jpg","facebook/auto/201905/b67606729ce3aafd17f969e74adcfe97.jpg"]
    }



